@extends('new.layouts.indexPublic')
@section('title'){{ $jobinfo->job_title.'招聘'.(empty($jobinfo->recruiting_num)?'若干':$jobinfo->recruiting_num).'名_'.$jobinfo->company_basic->company_name.'_'.Site::get('webname') }} @endsection

{{--职位详情页css--}}
@section('headcss')
    <meta name="keywords" content="{{Site::get('homekeywords')}}">
    <meta name="description" content="{{Site::get('homedescription')}}">
    @parent
    <link rel="stylesheet" href="{{asset('/new/css/index/jobInfo.css')}}">
@endsection

{{--主体内容--}}
@section('content')
    {{--主导航--}}
    @include('new.layouts.mainNav')
    {{--主导航结束--}}

    {{--主要内容--}}
    <div class="main">
        <div class="wrapper">
            {{--基本信息--}}
            <div class="baseInfo">
                <h2>
                    <span>{{str_limit($jobinfo->job_title,36)}}</span>
                    @if(!empty($jobinfo->part_status) && $jobinfo->part_status == '2')
                        <i class="two status"></i>
                    @elseif(!empty($jobinfo->part_status) && $jobinfo->part_status == '3')
                        <i class="three status"></i>
                    @elseif(!empty($jobinfo->part_status) && $jobinfo->part_status == '4')
                        <i class="four status"></i>
                    @endif
                </h2>
                <p class="salary">¥ {{ $jobinfo->salary_above }}</p>
                <p class="publishTime">{{$jobinfo->addtime}}</p>
                <ul class="welfare">
                    @if(count($jobinfo->welfare) > 0 && is_array($jobinfo->welfare) )
                        @foreach($jobinfo->welfare as $v)
                            <li>{{ $v }}</li>
                        @endforeach
                    @endif
                </ul>
                <ul class="details">
                    <li><span>招聘部门</span>{{ empty($jobinfo->dePartMent)?'不限':$jobinfo->dePartMent}}</li>
                    <li><span>招聘人数</span>{{ empty($jobinfo->recruiting_num)?"若干名":$jobinfo->recruiting_num.'人' }}</li>
                    <li><span>学历要求</span>{{ empty($jobinfo->education)?'不限':$jobinfo->education }}</li>
                    <li><span>工作经验</span>{{ empty($jobinfo->work_year)?'不限':$jobinfo->work_year }}</li>
                    <li><span>性别要求</span>{{ empty($jobinfo->gender)?'不限':$jobinfo->gender }}</li>
                    <li><span>年龄要求</span>{{ empty($jobinfo->age)?'不限':$jobinfo->age }}</li>
                    <li class="location">
                        <span>工作地点</span>
                        <p>{{ $jobinfo->company_basic->address }}</p>
                        <a id="busLine" href="javascript:void(0)">查询路线</a>
                    </li>
                </ul>
                @if($favoritesStatus==0)
                    <a class="collect {{ $favoritesBtton }}" id="collect" href="javascript:void(0)">收藏</a>
                @else
                    <a class="collect {{ $favoritesBtton }} collected" id="collect" href="javascript:void(0)">收藏</a>
                @endif
                <a id="toShare" class="toShare" href="javascript:void(0)">分享</a>
                <button class="submit {{ $applyJobButton }}" href="javascript:void(0)">投递简历</button>
            </div>
            {{--基本信息结束--}}
            <div class="content">
                {{--职位发布者--}}
                <div class="publisher">
                    <h2><span>{{ $jobinfo->contacts or '保密' }}</span></h2>
                    <div class="box">
                        <div class="left">
                            <span class="avatar"><img src="{{ asset($jobinfo->logo) }}" alt="发布人头像"></span>
                            <p class="name">{{ $jobinfo->contacts or '保密' }}</p>
                            <p class="photoNum">
                                @if($contactInfo==1)
                                    <span id="thShowContact">{{ $contactMobile  }}</span>
                                @elseif($contactInfo==2)
                                    @if(auth()->guard('personal')->check())
                                        <span id="thShowContact">{{ $contactMobile  }}</span>
                                    @else
                                        <span id="thShowContact">{{ $contactMobile  }}</span>
                                        <a id="showContantButton" class="{{ $contactButton or '' }}">[ 查看 ]</a>
                                    @endif
                                @elseif($contactInfo==3)
                                    @if(auth()->guard('personal')->check())
                                        @if($to_view==1)
                                            <span id="thShowContact">{{ $contactMobile  }}</span>
                                        @elseif($to_view==2)
                                            <span id="thShowContact">{{ $contactMobile  }}</span>
                                            <a id="showContantButton"
                                               onclick="to_view('{{$jobid}}','{{$to_view}}')">[ 查看 ]</a>
                                        @elseif($to_view==3)
                                            <span id="thShowContact">{{ $contactMobile  }}</span>
                                            <a id="showContantButton"
                                               onclick="to_view('{{$jobid}}','{{$to_view}}')">[ 查看 ]</a>
                                        @endif
                                    @else
                                        <span id="thShowContact">{{ $contactMobile  }}</span>
                                        <a id="showContantButton" onclick="dispense()">[ 查看 ]</a>
                                    @endif
                                @else
                                    <span id="thShowContact">{{ $contactMobile  }}</span>
                                    <a id="showContantButton" class="{{ $contactButton or '' }}">[ 查看 ]</a>
                                @endif
                            </p>
                        </div>
                        <div class="center">
                            <p class="p1">{{ $resumeRecoveryRate }}</p>
                            <p class="p2">简历平均回复率</p>
                        </div>
                        <div class="right">
                            <p class="p1">{{ $last_login_time or '' }}</p>
                            <p class="p2">企业最近查看</p>
                        </div>
                    </div>
                </div>
                {{--职位发布者结束--}}
                {{--职位描述--}}
                <div class="descriptions">
                    <h2><span>职位描述</span></h2>
                    <div class="box">{!! nl2br(e($jobinfo->description)) !!}</div>

                </div>
                {{--职位描述结束--}}

                {{--公司简介--}}
                <div class="introduce">
                    <h2><span>公司简介</span></h2>
                    <div class="box">{{ ($jobinfo->company_basic->profile) }}</div>
                </div>
                {{--公司简介结束--}}

                {{--公司其他职位--}}
                <div class="otherJobs">
                    <h2><span>该公司其他职位</span><a id="more_job" class="seeMore" href="javascript:void(0)">更多</a></h2>
                    <ul>
                        @if(count($recommendedjob) > 0)
                            @foreach($recommendedjob as $k=>$v)
                                @if(($k+1) % 3 != 0)
                                    <li>
                                        <span class="col1">
                                            <a href="{{url('jobinfo_'.idEncryption($v->id).'.html')}}" target="_blank">{{str_limit($v->job_title,20)}}</a>
                                        </span>
                                        <span class="col2">{{ $v->salary_above }}</span>
                                        <span class="col3">{{ $v->location1 }}</span>
                                    </li>
                                @else
                                    <li class="noMarginRight">
                                        <span class="col1">
                                            <a href="{{url('jobinfo_'.idEncryption($v->id).'.html')}}">{{str_limit($v->job_title,20)}}</a>
                                        </span>
                                        <span class="col2">{{ $v->salary_above }}</span>
                                        <span class="col3">{{ $v->location1 }}</span>
                                    </li>
                                @endif
                            @endforeach
                        @else
                            <li class="noJob">该公司暂无其他职位。。。</li>
                        @endif

                    </ul>
                </div>
                {{--公司其他职位结束--}}
            </div>
            <div class="aside">
                {{--公司信息--}}
                <div class="company">
                    <a href="javascript:void(0)" class="companyLogo"><img src="{{asset($jobinfo->logo)}}" width="55" height="55" alt="公司logo"></a>
                    <div class="box">
                        <a href="{{url('comabout_'.idEncryption($jobinfo->company_basic->id).'.html')}}" target="_blank">{{str_limit($jobinfo->company_basic->company_name,30)}}</a>
                        <span>{{$jobinfo->location}}</span>
                    </div>
                    <ul>
                        <li><span>行业</span>{{str_limit($jobinfo->industry,24)}}</li>
                        <li><span>性质</span>{{$jobinfo->company_basic->comkind}}</li>
                        <li><span>规模</span>{{$jobinfo->company_basic->employee_num}}</li>
                        <li><span>地址</span>{{$jobinfo->company_basic->address}}</li>
                    </ul>
                </div>
                {{--公司信息结束--}}

                {{--相似职位--}}
                <div class="similarJobs">
                    <h2><span>相似职位</span></h2>
                    <ul>
                        @if(count($right_jobinfo) > 0)
                            @foreach($right_jobinfo as $k => $right_jobinfo_value)
                                <li>
                                    <a class="compLogo" href="{{url('jobinfo_'.idEncryption($right_jobinfo_value->id).'.html')}}" target="_blank">
                                        @if(!empty($right_jobinfo_value->company_basic->logo))
                                            <img src='{{ asset("upload/companylogo/".$right_jobinfo_value->company_basic->logo) }}' width="52" height="52">
                                        @else
                                            <img src='{{ asset('/default/images/index/default_company_img.jpg') }}' width="52" height="52">
                                        @endif
                                    </a>
                                    <p class="p1">
                                        <a href="{{url('comabout_'.idEncryption($right_jobinfo_value->company_basic->id).'.html')}}" target="_blank">
                                            {{ str_limit($right_jobinfo_value->company_basic->company_name,20)}}
                                        </a>
                                    </p>
                                    <p class="p2">
                                        <a href="{{url('jobinfo_'.idEncryption($right_jobinfo_value->id).'.html')}}" target="_blank">
                                            {{ str_limit($right_jobinfo_value->job_title,20)}}
                                        </a>
                                    </p>
                                    <p class="p3">{{ $right_jobinfo_value->salary_above }}</p>
                                </li>
                            @endforeach
                        @else
                            <li class="noJob">抱歉，暂时没有相似职位。。。</li>
                        @endif
                    </ul>
                </div>
                {{--相似职位结束--}}
            </div>
        </div>
    </div>
    {{--主要内容--}}
    <?php
    ?>
@endsection

{{--首页js--}}
@section('js')
    @parent
    <script type="text/javascript" src="{{Resources::jsOption(['education'])}}"></script>
    <script type="text/javascript" src="{{asset('/default/js/jquery/jquery.validate.min.js')}}"></script>
    <script type="text/javascript" src="{{asset('/default/js/jquery/jquery.validate.extend.js')}}"></script>
    <script type="text/javascript" src="{{asset('/default/js/jquery/jquery.form.js')}}"></script>
    {{--工作岗位--}}
    <script type="text/javascript" src="{{asset('/default/js/jquery/jquery.position.js')}}"></script>
    {{--工作地区--}}
    <script type="text/javascript" src="{{asset('/default/js/jquery/jquery.area.js')}}"></script>
    <script type="text/javascript" src="{{asset('/new/js/index/ejectlogin.js')}}"></script>
    <script type="text/javascript" src="{{asset('/default/js/jquery/jquery.autoTime.js')}}"></script>
    <script type="text/javascript" src="{{asset('/default/js/index/reginfo.js')}}"></script>
    <script>
        //加载登录事件
        var postUrl = "{{ url('personal/ajax_login') }}";
        var _token = "{{csrf_token()}}";
        var ajaxMobileLogin = "{{ url('personal/ajax_mobile_login') }}";
        //短信验证发送
        var codeUrl = "{{ url('common/ajax_code') }}";
        var imgCode = "{{captcha_src('code')}}" + Math.random();
        var mobCodeUrl;

        $(function(){

            //未登录时收藏、投递简历按钮点击事件
            $(".personlogin").click(function(){
                //留下基本信息面试通知
                dispense();
            });
            //收藏
            $(".baseInfo .personFavorites").click(function(){
                $.ajax({
                    url: "{{ url("personal/personfavorites") }}",
                    dataType: "json",
                    data: "jobid={{$jobid}}&comid={{$company_id}}",
                    type: "GET",
                    time: 0,
                    success: function(data){
                        switch(data.status){
                            case 0:
                                layer.msg(data.msg, {icon: 6});
                                $("#collect").addClass('collected');
                                return true;
                                break;
                            case 1:
                                layer.msg(data.msg, {icon: 5});
                                $("#collect").removeClass('collected');
                                break;
                            default:
                                layer.msg(data.msg, {icon: 5});
                                break;
                        }
                    },
                    error: function(data){
                        var msgErr = '';
                        var errors = $.parseJSON(data.responseText);
                        $.each(errors, function(index, value){
                            msgErr += value + ";<br>";
                        });
                        layer.msg(msgErr, {icon: 5});
                    },
                    complete: function(){
                    }
                });
                return false;
            });

            //分享
            $("#toShare").click(function(){
                layer.open({
                    type: 1,
                    title: '分享朋友圈',
                    skin: 'layer-toShare',
                    area: ['240px', '295px'],
                    resize: false,
                    move: false,
                    btn: false,
                    content: '<div class="box"><img src="{{url('to_share?job_id='.$jobid)}}"></div><div style="text-align: center">扫一扫分享到朋友圈</div>'
                });
            });

            //申请职位
            $(".baseInfo .applyjob").click(function(){
                $.ajax({
                    url: "{{ url("personal/applyjob") }}",
                    dataType: "json",
                    data: "jobid={{$jobid}}",
                    type: "GET",
                    time: 0,
                    success: function(data){
                        switch(data.status){
                            case 0:
                                $(this).html('已申请该职位');
                                layer.msg(data.msg, {icon: 6});
                                if(data.showStatus){
                                    $("#thShowContact").html(str_trim(data.contact.mobile + ' , ' + data.contact.phone, ','));
                                    $("#showContantButton").remove();
                                }
                                return true;
                                break;
                            case 1:
                                layer.msg(data.msg, {icon: 5});
                                break;
                            case 2:
                                layer.confirm(data.msg, {icon: 3, title: '提示'}, function(index){
                                    //do something
                                    location.href = "{{ url("/personal/my_resume") }}";
                                    layer.close(index);
                                });
                                break;
                            default:
                                layer.msg(data.msg, {icon: 5});
                                break;
                        }
                    },
                    error: function(data){
                        var msgErr = '';
                        var errors = $.parseJSON(data.responseText);
                        $.each(errors, function(index, value){
                            msgErr += value + ";<br>";
                        });
                        layer.msg(msgErr, {icon: 5});
                    },
                    complete: function(){
                    }
                });
                return false;
            });

            //查看公交线路
            $(function(){
                $("#busLine").click(function(){
                    var index = parent.layer.getFrameIndex("baiduMap");
                    layer.open({
                        type: 1,
                        title: '查看公交路线',
                        skin: 'layer-toshare',
                        area: ['865px', '570px'],
                        resize: false,
                        move: false,
                        btn: false,
                        content: '<iframe frameborder="0" name="baiduMap" id="baiduMap" width="820" height="500" src="{{ route("baiduMap",["cid"=>idEncryption($jobinfo->company_basic->id)]) }}" scrolling="no"></iframe>'
                    });
                });
            });

            //公司所有简历查看更多按钮
            $("#more_job").click(function(){
                location.href = "{{url('/job?keyword=').$jobinfo->company_basic->company_name}}";
            });

        });

        //已有账号登录
        function haveLgoin(){
            layer.closeAll();
            mobCodeUrl = "{{ url('personal/ajax_mob_login_code') }}";
            $.personEject({
                className: "personlogin",
                QQLogin: "{{ Site::get('personAppid') }}",
                QQUrl: "{{ url("personal/qqlogin") }}",
                weiXinUrl: "{{ weiXinlogin('personal') }}",
                csrf: "{{ csrf_token() }}",
                callBack: function(status){}
            });
        }
    </script>
@endsection
